gtk/gtkfilechooserdefault.c (shortcuts_append_home,
authorTor Lillqvist <tml@iki.fi>
Sat, 14 Aug 2004 16:47:48 +0000 (16:47 +0000)
committerTor Lillqvist <tml@src.gnome.org>
Sat, 14 Aug 2004 16:47:48 +0000 (16:47 +0000)
2004-08-14  Tor Lillqvist  <tml@iki.fi>

* gtk/gtkfilechooserdefault.c (shortcuts_append_home,
shortcuts_append_desktop, set_local_only)
* gtk/gtkfilesystemwin32.c (gtk_file_system_win32_render_icon)
* gtk/gtkpathbar.c (find_button_type, _gtk_path_bar_set_file_system):
Guard against g_get_home_dir() returning NULL. (#150007)

ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-6
ChangeLog.pre-2-8
gtk/gtkfilechooserdefault.c
gtk/gtkfilesystemwin32.c
gtk/gtkpathbar.c

index 5f988723f554f08b65c354521cfcde7f817a4972..5cac1e9f5811b3630e517b3a0e503c7792c702c1 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2004-08-14  Tor Lillqvist  <tml@iki.fi>
+
+       * gtk/gtkfilechooserdefault.c (shortcuts_append_home,
+       shortcuts_append_desktop, set_local_only)
+       * gtk/gtkfilesystemwin32.c (gtk_file_system_win32_render_icon)
+       * gtk/gtkpathbar.c (find_button_type, _gtk_path_bar_set_file_system): 
+       Guard against g_get_home_dir() returning NULL. (#150007)
+
 Sat Aug 14 17:56:33 2004  Soeren Sandmann  <sandmann@daimi.au.dk>
 
        * gtk/gtkentry.c (gtk_entry_get_pixel_ranges): New function. 
index 5f988723f554f08b65c354521cfcde7f817a4972..5cac1e9f5811b3630e517b3a0e503c7792c702c1 100644 (file)
@@ -1,3 +1,11 @@
+2004-08-14  Tor Lillqvist  <tml@iki.fi>
+
+       * gtk/gtkfilechooserdefault.c (shortcuts_append_home,
+       shortcuts_append_desktop, set_local_only)
+       * gtk/gtkfilesystemwin32.c (gtk_file_system_win32_render_icon)
+       * gtk/gtkpathbar.c (find_button_type, _gtk_path_bar_set_file_system): 
+       Guard against g_get_home_dir() returning NULL. (#150007)
+
 Sat Aug 14 17:56:33 2004  Soeren Sandmann  <sandmann@daimi.au.dk>
 
        * gtk/gtkentry.c (gtk_entry_get_pixel_ranges): New function. 
index 5f988723f554f08b65c354521cfcde7f817a4972..5cac1e9f5811b3630e517b3a0e503c7792c702c1 100644 (file)
@@ -1,3 +1,11 @@
+2004-08-14  Tor Lillqvist  <tml@iki.fi>
+
+       * gtk/gtkfilechooserdefault.c (shortcuts_append_home,
+       shortcuts_append_desktop, set_local_only)
+       * gtk/gtkfilesystemwin32.c (gtk_file_system_win32_render_icon)
+       * gtk/gtkpathbar.c (find_button_type, _gtk_path_bar_set_file_system): 
+       Guard against g_get_home_dir() returning NULL. (#150007)
+
 Sat Aug 14 17:56:33 2004  Soeren Sandmann  <sandmann@daimi.au.dk>
 
        * gtk/gtkentry.c (gtk_entry_get_pixel_ranges): New function. 
index 5f988723f554f08b65c354521cfcde7f817a4972..5cac1e9f5811b3630e517b3a0e503c7792c702c1 100644 (file)
@@ -1,3 +1,11 @@
+2004-08-14  Tor Lillqvist  <tml@iki.fi>
+
+       * gtk/gtkfilechooserdefault.c (shortcuts_append_home,
+       shortcuts_append_desktop, set_local_only)
+       * gtk/gtkfilesystemwin32.c (gtk_file_system_win32_render_icon)
+       * gtk/gtkpathbar.c (find_button_type, _gtk_path_bar_set_file_system): 
+       Guard against g_get_home_dir() returning NULL. (#150007)
+
 Sat Aug 14 17:56:33 2004  Soeren Sandmann  <sandmann@daimi.au.dk>
 
        * gtk/gtkentry.c (gtk_entry_get_pixel_ranges): New function. 
index bdb7e84f6dc0e324d31dfae6411baffcb5fdd030..f0a92254105ebbb09d55b58eb7780921d1808e52 100644 (file)
@@ -1079,6 +1079,9 @@ shortcuts_append_home (GtkFileChooserDefault *impl)
   GError *error;
 
   home = g_get_home_dir ();
+  if (home == NULL)
+    return;
+
   home_path = gtk_file_system_filename_to_path (impl->file_system, home);
 
   error = NULL;
@@ -1093,10 +1096,15 @@ shortcuts_append_home (GtkFileChooserDefault *impl)
 static void
 shortcuts_append_desktop (GtkFileChooserDefault *impl)
 {
+  const char *home;
   char *name;
   GtkFilePath *path;
 
-  name = g_build_filename (g_get_home_dir (), "Desktop", NULL);
+  home = g_get_home_dir ();
+  if (home == NULL)
+    return;
+
+  name = g_build_filename (home, "Desktop", NULL);
   path = gtk_file_system_filename_to_path (impl->file_system, name);
   g_free (name);
 
@@ -3318,7 +3326,12 @@ set_local_only (GtkFileChooserDefault *impl,
           * such a situation, so we ignore errors.
           */
          const gchar *home = g_get_home_dir ();
-         GtkFilePath *home_path = gtk_file_system_filename_to_path (impl->file_system, home);
+         GtkFilePath *home_path;
+
+         if (home == NULL)
+           return;
+
+         home_path = gtk_file_system_filename_to_path (impl->file_system, home);
 
          _gtk_file_chooser_set_current_folder_path (GTK_FILE_CHOOSER (impl), home_path, NULL);
 
index 9c72f208fee92e33327665732d5317c26a4d4332..fd68a339ab6d373bf2b790aa7363bfccf8ba9d91 100644 (file)
@@ -1101,7 +1101,8 @@ gtk_file_system_win32_render_icon (GtkFileSystem     *file_system,
     }
   else if (g_file_test (filename, G_FILE_TEST_IS_DIR))
     {
-      if (0 == strcmp (g_get_home_dir(), filename))
+      const gchar *home = g_get_home_dir ();
+      if (home != NULL && 0 == strcmp (home, filename))
         icon_set = gtk_style_lookup_icon_set (widget->style, GTK_STOCK_HOME);
       else
         icon_set = gtk_style_lookup_icon_set (widget->style, GTK_STOCK_DIRECTORY);
index e3cbe7d580b3f4923533ee41b594bf96c6c69fde..bd8516f611eafff5a0d8c9d35a61db38c6a70184 100644 (file)
@@ -916,11 +916,14 @@ static ButtonType
 find_button_type (GtkPathBar  *path_bar,
                  GtkFilePath *path)
 {
-  if (! gtk_file_path_compare (path, path_bar->root_path))
+  if (path_bar->root_path != NULL &&
+      ! gtk_file_path_compare (path, path_bar->root_path))
     return ROOT_BUTTON;
-  if (! gtk_file_path_compare (path, path_bar->home_path))
+  if (path_bar->home_path != NULL &&
+      ! gtk_file_path_compare (path, path_bar->home_path))
     return HOME_BUTTON;
-  if (! gtk_file_path_compare (path, path_bar->desktop_path))
+  if (path_bar->desktop_path != NULL &&
+      ! gtk_file_path_compare (path, path_bar->desktop_path))
     return DESKTOP_BUTTON;
 
  return NORMAL_BUTTON;
@@ -1170,11 +1173,22 @@ _gtk_path_bar_set_file_system (GtkPathBar    *path_bar,
   path_bar->file_system = g_object_ref (file_system);
 
   home = g_get_home_dir ();
-  desktop = g_build_filename (home, "Desktop", NULL);
-  path_bar->home_path = gtk_file_system_filename_to_path (path_bar->file_system, home);
-  path_bar->desktop_path = gtk_file_system_filename_to_path (path_bar->file_system, desktop);
+  if (home != NULL)
+    {
+      path_bar->home_path = gtk_file_system_filename_to_path (path_bar->file_system, home);
+      /* FIXME: Need file system backend specific way of getting the
+       * Desktop path.
+       */
+      desktop = g_build_filename (home, "Desktop", NULL);
+      path_bar->desktop_path = gtk_file_system_filename_to_path (path_bar->file_system, desktop);
+      g_free (desktop);
+    }
+  else
+    {
+      path_bar->home_path = NULL;
+      path_bar->desktop_path = NULL;
+    }
   path_bar->root_path = gtk_file_system_filename_to_path (path_bar->file_system, "/");
-  g_free (desktop);
 }
 
 /**